home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7340 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  55 lines

  1. Path: sun001.spd.dsccc.com!spd!jmccarty
  2. From: jmccarty@spd.dsccc.com (Mike McCarty)
  3. Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
  4. Subject: Re: Access carry flag from C
  5. Date: 22 Feb 1996 20:00:24 GMT
  6. Organization: DSC Communications Corporation, Plano, Texas USA
  7. Message-ID: <4gii0o$38k@sun001.spd.dsccc.com>
  8. References: <Dn1C9z.DGv.0.net@indra.com> <31298D20.41C6@bazis.nl> <ARTHUR.96Feb20143404@gold.Smallworld.co.uk> <TANMOY.96Feb20101110@qcd.lanl.gov>
  9. NNTP-Posting-Host: aplo139.spd.dsccc.com
  10.  
  11. In article <TANMOY.96Feb20101110@qcd.lanl.gov>,
  12. Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> wrote:
  13. )In article <ARTHUR.96Feb20143404@gold.Smallworld.co.uk>
  14. )arthur@Smallworld.co.uk (Arthur Chance) writes: 
  15. )<snip>
  16. )   In article <31298D20.41C6@bazis.nl> Franz Korntner <fkorntne@bazis.nl> writes:
  17. )   > j+k will overflow when the result exceeds MAXINT
  18. )   > 
  19. )   > Thus:  "if (j+k > MAXINT) overflow();" but the operation is undefined
  20. )   > if the result overflows, so the expression needs rewriting to make sure
  21. )   > this doesn't happen. The result is then "if (j>MAXINT-k) overflow();".
  22. )
  23. )   As we must be talking about signed ints, because unsigned can't cause
  24. )   undefined behaviour by overflow, if k < 0, then MAXINT-k overflows.
  25. )
  26. )   Basically, the C *standard* is useless on things like signed overflow
  27. )   (or word size, or what happens with right shift of -ve numbers, or
  28. )   <insert your favourite "undefined behaviour" gripe here>). You have
  29. )   to look carefully at each *implementation* you use. You can usually
  30.  
  31. If I recall the first post properly, no mention was made of "int" types,
  32. but rather of fixed-point types. Not all fixed-point numeration systems
  33. represent integers.
  34.  
  35. )Actually you are mixing up the concepts of `undefined behaviour' and
  36. )`implementation-defined behaviour'. In the case of the former, even
  37. )looking at the implementation documentation need not be sufficient: in
  38. )the latter, the documentation has to tell you what happens.
  39. )
  40. )Cheers
  41. )Tanmoy
  42. )--
  43. )tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  44. )Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  45. )Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  46. )<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  47. )internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  48. )fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  49.  
  50.  
  51. ----
  52. char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  53.  
  54. I don't speak for DSC.         <- They make me say that.
  55.